import request from '@/config/axios'
import {PaymentVO} from "@/api/dispatch/payment";

// 派单收款单 VO
export interface ReceiptVO {
  id: number // 订单编号
  dispatchOrderNo: string // 派单订单no
  storeName: string // 门店名称
  storeId: number // 服务门店
  dispatchOrderId: number // 派单订单
  no: string // 订单编号
  remark: string // 备注
  status: number // 开启状态
  sort: number // 排序
  carType: string // 车型
  receiptPrice: number // 收款金额
  discountPrice: number // 优惠金额
  receiptStatus: boolean // 收款状态
  receiptAmount: number // 已收金额
  unreceiptAmount: number // 未收金额
  checkStatus: boolean // 对账状态
  checkDate: Date // 对账时间
  channelName: string // 渠道名称
}

// 派单收款单 API
export const ReceiptApi = {
  // 查询派单收款单分页
  getReceiptPage: async (params: any) => {
    return await request.get({ url: `/dispatch/receipt/page`, params })
  },

  // 查询派单收款单详情
  getReceipt: async (id: number) => {
    return await request.get({ url: `/dispatch/receipt/get?id=` + id })
  },

  getByDispatchOrderId: async (id) => {
    return await request.get({ url: `/dispatch/receipt/getByDispatchOrderId/` + id })
  },

  handleBatchCancelReconciliation: async (data) => {
    return await request.put({url: `/dispatch/receipt/handleBatchCancelReconciliation`, data})
  },

  //批量对账
  handleBatchReconciliation: async (data) => {
    return await request.put({url: `/dispatch/receipt/handleBatchReconciliation`, data})
  },

  //确认收款
  handleReceipt: async (data) => {
    return await request.put({url: `/dispatch/receipt/handleReceipt`, data})
  },

  // 批量收款
  handleBatchReceipt: async (data) => {
    return await request.put({url: `/dispatch/receipt/handleBatchReceipt`, data})
  },

  // 批量撤销收款
  handleBatchCancelReceipt: async (data) => {
    return await request.put({url: `/dispatch/receipt/handleBatchCancelReceipt`, data})
  },

  //撤销付款
  cancelReceipt: async (id: number) => {
    return await request.put({url: `/dispatch/receipt/cancelReceipt?id=` + id})
  },

  // 新增派单收款单
  createReceipt: async (data: ReceiptVO) => {
    return await request.post({ url: `/dispatch/receipt/create`, data })
  },

  // 修改派单收款单
  updateReceipt: async (data: ReceiptVO) => {
    return await request.put({ url: `/dispatch/receipt/update`, data })
  },

  // 删除派单收款单
  deleteReceipt: async (id: number) => {
    return await request.delete({ url: `/dispatch/receipt/delete?id=` + id })
  },

  // 导出派单收款单 Excel
  exportReceipt: async (params) => {
    return await request.download({ url: `/dispatch/receipt/export-excel`, params })
  },
}
